      IMPLICIT REAL*8 (A-H, L-Z)
      real*8 porb(10000),N(10000)
      real*8 p(100),m(100),a(100),b(100),e(100)
      real*8 porb1,md1,dt1,dt2,dt3(100,100)
      real*8 m1,m2,tb0,mx,mx2,tbx,kwx,kwx2,eccx,spin2,t1,t2 
      integer i,j,k
      open(4,file='hmxb.dat',status='unknown')
      open(1001,file='hmxb',status='unknown')      
      p(0) = -0.5
      m(0) = 2.0
      e(0) = 0.0


      do i = 1, 73
      m(i) = m(i-1) + 0.25

       do j = 1, 36
       p(j) = p(j-1) + 0.1

      


      rewind(4)
      dt2 = 0      
      do k = 1,24128
      read(4,*)m1,m2,tb0,mx,mx2,tbx,eccx,t1,t2
      rate = 1.18e-6*m2*m1**-2.7
c      tbx = tbx*(1-eccx**2)**1.5
      dt1 = rate
      tbx = log10(tbx)
      if(mx.le.m(i).and.mx.gt.m(i-1).and.
     &  tbx.gt.p(j-1).and.tbx.le.p(j))then
      
      dt2 = dt2+dt1
      dt3(i,j) = dt2
      endif


      enddo

      write(1001,11)m(i-1),p(j-1),dt3(i,j)     
11    format(2f8.3,1E12.2,1f8.3)

      enddo
      enddo      
      end

            
